#include<unistd.h>
#include"process.h"
#include<string.h>

#define NUM 101
#define STYLE '#'

void FlushProcess(double total,double current)
{
    char buffer[NUM];
    memset(buffer,'\0',sizeof buffer);
    const char *lable="|/-\\";
    int len=strlen(lable);
    static int cnt=0;
    int num=(int)(current*100/total);
    for(int i=0;i<num;i++)
    {
        buffer[i]=STYLE;
    }
    double rate=current*100/total;
    cnt%=4;
    printf("[%-100s][%.1lf%%][%c]\r",buffer,rate,lable[cnt]);
    cnt++;
    fflush(stdout);
}
